package logic

import (
	"context"
	"jd_srv/internal/svc"
	"jd_srv/jd"
	"jd_srv/models"

	"github.com/zeromicro/go-zero/core/logx"
)

type AuditListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAuditListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AuditListLogic {
	return &AuditListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AuditListLogic) AuditList(in *jd.AuditListRequest) (*jd.AuditListResponse, error) {
	// todo: add your logic here and delete this line
	var as []models.AuditLog
	var listAs []*jd.ListAudit

	models.DB.Find(&as)

	for _, a := range as {
		list := jd.ListAudit{
			GoodsId:     a.GoodsId,
			AuditStatus: a.AuditStatus,
		}
		listAs = append(listAs, &list)
	}

	return &jd.AuditListResponse{
		List: listAs,
	}, nil
}
